const app = getApp()
let host = app.globalData.host;
Page({
 
  /**
   * 页面的初始数据
   */
  data: {
  },
 
  //表单提交
  formSubmit(e){

    this.setData({
      information: e.detail.value,
      modalHidden:false
    });

    let {cropId,cropName,cropDeviceSerial} = e.detail.value
    wx.request({
      url: host+'/updateGrowthNotes',
      data: {
        cropId: cropId,
        cropName: cropName,
        cropDeviceSerial: cropDeviceSerial
      },
      method: "POST",
      header: {
        'content-type': 'application/x-www-form-urlencoded' // 默认值
      },success (res) {
      console.log(res.data)
      },
      fail (error){
        console.log("失败")
      }
    })
    wx.redirectTo({
      url: '../home/home',
    })

  },

  onLoad: function (options) {
    let that = this
    let cropId = options.cropId
    wx.request({
      url: host+'/showGrowthNotes?cropId='+cropId,
      method: "GET",
      header: {
        'content-type': 'application/x-www-form-urlencoded' // 默认值
      },success (res) {
        that.setData({
          cropId: res.data.cropId,
          cropName: res.data.cropName,
          cropDeviceSerial: res.data.cropDeviceSerial
        })
      },
      fail (error){
        console.log("失败")
      }
    })
  }
})

